package com.syg.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author syg
 */
@RestController
public class Jvm {

    @RequestMapping("/omit")
    public void testOmitStackTraceInFastThrow() {

    }

    /***
     * 栈深度溢出
     */
    @RequestMapping("/testStack")
    public void testStackOverFlow(){
        Jvm omit = new Jvm();
        omit.testStackOverFlow();
    }

    /**
     * 堆内存溢出
     */
    @RequestMapping("/testHeap")
    public void testHeap() {
        int i=0;
        try{
            List<String> list=new ArrayList<>();
            String a="hello";
            while (true){
                list.add(a);
                a=a+a;
                i++;
            }
        }catch (Throwable e){
            e.printStackTrace();
        }
    }


}
